﻿import re

__author__ = 'LEO'
# -*- coding: utf-8 -*-

pattern = re.compile(r'hello')

result1 = re.match(pattern,'hello')
result2 = re.match(pattern,'helloo LEO')
result3 = re.match(pattern,'helo LEO')
result4 = re.match(pattern,'hello LEO')

if result1:
    print result1.group()
else:
    print 'result1 匹配失败'

if result2:
    print result2.group()
else:
    print 'result2 匹配失败'

if result3:
    print result3.group()
else:
    print 'result3 匹配失败'
    
if result4:
    print result4.group()
else:
    print 'result4  匹配失败'